Programming With QuickTime VR 2.1

Previous | Overview | Contents | Next

Reading a QuickTime VR World

A QuickTime VR movie contains information describing the locations of nodes in the movie as well as general information about the movie. This information is stored in an atom container, defined by the QTAtomContainer data structure. An atom container is a collection of atoms. Atom containers were introduced in QuickTime version 2.1, which provides a complete library of routines to extract information from atom containers. The QuickTime VR Manager function QTVRGetVRWorld (QTVRGetVRWorld) retrieves the VR world atom container from a QuickTime VR movie file.

The VR world includes such information as the name for the entire scene, the default node ID, and default imaging properties. It also contains an atom for each node in the file, which describes where to find the node. During the authoring process, you can add custom atoms to the VR world atom container. QuickTime VR ignores these custom atoms, but they can be extracted using the atom functions by an application that knows how to use the information. For example, Listing 2 extracts some custom data of type 'PREF' from the VR world atom container and copies it into a handle.

Listing 2 Extracting a custom atom from a VR world

Handle MyGetPREFData (QTVRInstance theInstance)
{
    QTAtomContainer         theVRWorld;
    OSErr                   theErr;
    QTAtom                  theAtom;
    Handle                  theHandle = nil;

    //Get the VR world.
    theErr = QTVRGetVRWorld(theInstance, &theVRWorld);
    if (theErr == noErr) {
        //Get the atom of type 'PREF' with atom ID 1.
        theAtom = QTFindChildByID(theVRWorld, kParentAtomIsContainer,
                                                        'PREF', 1, nil);
        if (theAtom != 0) {
            //Allocate a relocatable block and copy atom data into it.
            theHandle = NewHandleClear(sizeof(MyPREFDataStruct));
            QTCopyAtomDataToHandle(theVRWorld, theAtom, theHandle);
        }
        QTDisposeAtomContainer(theVRWorld);
    }
    //Return the handle to the caller; caller must dispose of it.
    return(theHandle);
}

See Developer's Guide: QuickTime for Macintosh, Version 2.5 for information about the QuickTime atom functions QTFindChildByID, QTCopyAtomDataToHandle, and QTDisposeAtomContainer.


© 1997 Apple Computer, Inc.

Previous | Overview | Contents | Next